home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / BBS / MUBBS / MUBBS112.CPT / MUBBS112 / MUBBS Mod Shells 4_92.cpt / Shells / Module std routines / MUBBS Module.h < prev   
Text File  |  1992-02-26  |  12KB  |  337 lines

  1. /*
  2.  *  MUBBS Module.h
  3.  *
  4.  *    This program source code and it's compiled version is
  5.  *  Copyright (c) 1991 N. Hawthorn.
  6.  *  This program source code and it's compiled version IS NOT IN THE
  7.  *  PUBLIC DOMAIN ! Please read the "COPYRIGHT NOTICE / NH" file for details
  8.  *  regarding use of this program source code and it's compiled version.
  9.  *
  10.  *
  11.  * Don't modify this file !
  12.  *
  13.  */
  14.  
  15.  
  16.  
  17. #if THINK_C == 5
  18. #pragma options(!align_arrays)
  19. #endif
  20.  
  21. #if THINK_C != 5
  22. #include "MacTypes.h"
  23. #endif
  24.  
  25. #include "string.h"
  26. #include "ctype.h"
  27.  
  28. /* All of my GLOBALS and stuff for each c file to use  */
  29. /* these values MUST remain the same */
  30.  
  31. #ifndef NULL
  32. #define NULL        ((void *) 0)
  33. #endif
  34.  
  35. #define EOF                (-1)
  36. #define SEEK_SET        0
  37. #define SEEK_CUR        1
  38. #define SEEK_END        2
  39.  
  40. #define maxport 33  /* how many users we may have ever makes exactly maxport users */
  41. #define maxnamelength    33 /* max username length */
  42.  
  43. struct GS { /* all this is provided to modules for possible modification */
  44.  
  45. int
  46.     u,                   /* THIS IS THE ACTIVE USER NUMBER !! (starts at 0!)
  47.                         /* use this for every array's index ! */
  48.     users,                /* how many actual users for this particular set up */
  49.     localuser,            /* what user number the local user is (it's users -1) */
  50.     stacksize,            /* stacks for all, never over 32K !!*/
  51.     calls,              /* number of calls total since boot up */
  52.     connects,             /* number of connects since boot up */
  53.     logins,             /* number of logins since boot up */
  54.     debuglevel,            /* For debugging, will print special messages when over 1 */
  55.     resetmode,            /* 0= no system reload, 1= program reload only, 2= total reset OK */
  56.     timeminute,            /* One minute count, gets reset to 0 at 10 minutes */
  57.     noprint,            /* flag for stopping any print() to the Mac screen, for local log on */
  58.     forgetusers,        /* flag to make all ports dead, for first sysop log on */
  59.     switchcount,        /* count of times NOT switched, done in a IRQ, reset at switch */
  60.     reservedint1,        /* reserved, DO NOT USE ! */
  61.     reservedint2,        /* reserved, DO NOT USE ! */
  62.     reservedint3,        /* reserved, DO NOT USE ! */
  63.     online[maxport],    /* flag for when you are still online */
  64.     maxtime[maxport],    /* max time to timeout in input routines, in TICKS 1000=15secs 3000=45secs */
  65.     timeon[maxport],    /* minutes this user has been on this login */
  66.     timeallowed[maxport], /* minutes this user is allowed on for */
  67.     userpriv[maxport],    /* users privledge level */
  68.     userlines[maxport],    /* users terminal config for line counts */
  69.     usertimes[maxport],    /* users number of times on (to detect new users) */
  70.     logmode[maxport],    /* 0=No log file written for this user, 1=Log this user */
  71.     privacy[maxport],    /* 0=Don't bother me, handled by a Chat Module */
  72.     linecnt[maxport],    /* users actual output line count, the system does this for you */
  73.     cont[maxport],        /* users flag for continous output, no stopping */
  74.     carrdet[maxport],    /* for testing, detect carrier loss */
  75.     usedtr[maxport],    /* flag for using DTR for hang up */
  76.     nocheck[maxport],    /* flag for send to check for control characters (S or C) */
  77.     okcancel[maxport],    /* flag for text file send cancels */
  78.     cancel[maxport],    /* TRUE when cancel is pressed in the out routine */
  79.     monitor[maxport],    /* The monitor flag, if TRUE shows all output to Mac screen */
  80.     chatmode[maxport],    /* if >1 the chat module is called from in() */
  81.     local[maxport],        /* flag to tell if this user is at the Mac screen & keyboard */
  82.     language[maxport],    /* 0=english normal, 1=english with ANSI Graphics. */
  83.     noiseflag[maxport],    /* TRUE if line noise is present (if noise detect module installed) */
  84.     frontend[maxport],    /* TRUE if using a front end program (if front end module installed) */
  85.     answer[maxport],    /* TRUE if it's OK to answer the line (for maint period) */
  86.     nottransfer[maxport], /* flag for when you are not in a transfer, doesn't strip ctls */
  87.     reservedint4[maxport], /* reserved, DO NOT USE ! */
  88.     reservedint5[maxport], /* reserved, DO NOT USE ! */
  89.     reservedint6[maxport], /* reserved, DO NOT USE ! */
  90.     reservedint7[maxport], /* reserved, DO NOT USE ! */
  91.     reservedint8[maxport]; /* reserved, DO NOT USE ! */
  92.  
  93. long
  94.     newstacksize,        /* the total stack size allowed, system sets this up for you */
  95.     logincounts,        /* counter of logins total for system */
  96.     timems,                /* counter of 10 MS periods, gets reset each minute to 0 */
  97.     userfilepos[maxport], /* points to this users record in the userfile */
  98.     reservedlong1[maxport], /* reserved, DO NOT USE ! */
  99.     reservedlong2[maxport], /* reserved, DO NOT USE ! */
  100.     reservedlong3[maxport], /* reserved, DO NOT USE ! */
  101.     reservedlong4[maxport], /* reserved, DO NOT USE ! */
  102.     reservedlong5[maxport]; /* reserved, DO NOT USE ! */
  103.  
  104. float
  105.     version,            /* this release of MUBBS version number */
  106.     reservedfloat1,     /* reserved, DO NOT USE ! */
  107.     reservedfloat2,     /* reserved, DO NOT USE ! */
  108.     reservedfloat3;     /* reserved, DO NOT USE ! */
  109.  
  110. char
  111.     CR[maxport][4],            /* This is the CRLF string use this, don't do a send("]"). */
  112.     username[maxport][maxnamelength],    /* user's name */
  113.     userbaud[maxport][10],    /* user's baudrate */
  114.     userlast[maxport][maxnamelength],    /* last time user was on */
  115.     userlocation[maxport][65],    /* user's location*/
  116.     sysopname[33],    /* sysop's name for system */
  117.     systemname[41],    /* this systems's name */
  118.     modulename[maxport][27],    /* the name of the module being called now */
  119.     oldmodulename[maxport][27],    /* the calling module's name (a copy of modulename) */
  120.     keyboardbuf[50],    /* for buffering the Mac's keyborad DO NOT USE ! */
  121.     programmer[21],        /* Returned from a module, the programmers "credits" name */
  122.     modtype[maxnamelength], /* the module's type & version */
  123.     reservedchar1[(maxport-1)][maxnamelength], /* reserved, DO NOT USE ! */
  124.     reservedchar2[maxport][maxnamelength], /* reserved, DO NOT USE ! */
  125.     reservedchar3[maxport][maxnamelength], /* reserved, DO NOT USE ! */
  126.     reservedchar4[maxport][maxnamelength], /* reserved, DO NOT USE ! */
  127.     reservedchar5[maxport][maxnamelength]; /* reserved, DO NOT USE ! */
  128.  
  129. unsigned char
  130.     input[maxport];
  131.  
  132. long S;        /* module call back routine pointer */
  133. ProcPtr Js; /* module call back pointer to the routine */
  134. int moduleresult;    /* module result code, only valid right after return from module */
  135.                     /* or set FALSE if module couldn't be called */
  136.  
  137. ProcPtr seropen;    /* serial port open routine pointer */
  138. ProcPtr serclose;    /* serial port close routine pointer */
  139. ProcPtr serflush;     /* serial port flush routine pointer */
  140. ProcPtr serin;        /* serial port input routine pointer */
  141. ProcPtr serout;        /* serial port output routine pointer */
  142. ProcPtr serblkin;    /* Block serial port input routine pointer */
  143. ProcPtr serblkout;    /* Block serial port output routine pointer */
  144. ProcPtr in;         /* IN routine pointer */
  145. ProcPtr out;         /* OUT routine pointer */
  146. ProcPtr blkin;        /* Block IN routine pointer */
  147. ProcPtr blkout;     /* Block OUT routine pointer */
  148.  
  149. ProcPtr event1; /* Event loop routine pointer */
  150. ProcPtr event2; /* Event loop routine pointer */
  151. ProcPtr event3; /* Event loop routine pointer */
  152. ProcPtr event4; /* Event loop routine pointer */
  153. ProcPtr event5; /* Event loop routine pointer */
  154.  
  155. ProcPtr idle1;    /* Idle loop routine pointer */
  156. ProcPtr idle2;    /* Idle loop routine pointer */
  157. ProcPtr idle3;    /* Idle loop routine pointer */
  158. ProcPtr idle4;    /* Idle loop routine pointer */
  159. ProcPtr idle5;    /* Idle loop routine pointer */
  160.  
  161. ProcPtr extra1; /* RESERVED, DO NOT USE !! */
  162. ProcPtr extra2; /* RESERVED, DO NOT USE !! */
  163. ProcPtr extra3; /* RESERVED, DO NOT USE !! */
  164. ProcPtr extra4; /* RESERVED, DO NOT USE !! */
  165. ProcPtr extra5; /* RESERVED, DO NOT USE !! */
  166.  
  167.  
  168. }; /* end of struct "GS" */
  169.  
  170.  
  171.  
  172. /* Here's where we define our globals. In the "Main" file, we make them actual */
  173. /* globals. In any others, they are "extern" so that your code can find them. */
  174. /* this is done by maknig the word "globalx" change (nothing or extern). */
  175.  
  176. #ifdef INMAIN
  177. #define globalx 
  178. #else
  179. #define globalx extern
  180. #endif
  181.  
  182. globalx struct GS *G; /* our pointer to the main module's global struct */
  183.  
  184. globalx int mode[maxport]; /* what mode this module was called in */
  185.  
  186.  
  187.  
  188. /* routines used to access the "call back" routines in the main module */
  189.  
  190. #define godoit hh=G->Js; asm{move.l hh,a1} asm{UNLK A6} asm{JMP (a1)}
  191.  
  192. /* this is so that we don't have to do the -> thing all the time ! */
  193.  
  194. #define u G->u
  195.  
  196. /* this stuff is so that we can call the "stdio" routines in the main module */
  197.  
  198. #if THINK_C != 5
  199.  
  200. #ifndef __size_t
  201. #define __size_t
  202. typedef unsigned long size_t;
  203. #endif
  204.  
  205. #endif
  206.  
  207. typedef unsigned long fpos_t;
  208.  
  209. typedef struct {
  210.     unsigned        std : 1;
  211.     unsigned        binary : 1;
  212.     unsigned        eof : 1;
  213.     unsigned        err : 1;
  214.     unsigned        dirty : 1;
  215.     unsigned        mybuf : 1;
  216.     unsigned        append : 1;
  217.     unsigned        delete : 1;
  218.     unsigned        pushed : 1;
  219.     char            one;
  220.     unsigned char    pushc;
  221.     short            refnum;
  222.     char            *buf;
  223.     size_t            size;
  224.     unsigned char    *ptr;
  225.     size_t            cnt;
  226.     fpos_t            pos;
  227.     fpos_t            len;
  228.     void            *window;
  229.     int                (*proc)();
  230. } FILE;
  231.  
  232. /* are we in the "MUBBS jump.c" file ?, if so don't compile this */
  233.  
  234. #ifndef INMUBBSJUMP
  235.  
  236. extern int remove(char *);
  237. extern int rename(char *, char *);
  238. extern FILE *tmpfile(void);
  239. extern char *tmpnam(char *);
  240.  
  241. extern int fclose(FILE *);
  242. extern int fflush(FILE *);
  243. extern FILE *fopen(char *, char *);
  244. extern FILE *freopen(char *, char *, FILE *);
  245. extern void setbuf(FILE *, char *);
  246. extern int setvbuf(FILE *, char *, int, size_t);
  247.  
  248. extern int fprintf(FILE *, char *, ...);
  249. extern int fscanf(FILE *, char *, ...);
  250. extern int printf(char *, ...);
  251. extern int scanf(char *, ...);
  252. extern int sprintf(char *, char *, ...);
  253. extern int sscanf(char *, char *, ...);
  254. extern int vfprintf(FILE *, char *, void *);
  255. extern int vprintf(char *, void *);
  256. extern int vsprintf(char *, char *, void *);
  257. extern int _vscanf(char *, void *);
  258. extern int _vsscanf(char *, char *, void *);
  259. extern int _vfscanf(FILE *, char *, void *);
  260.  
  261. extern int fgetc(FILE *);
  262. extern char *fgets(char *, int, FILE *);
  263. extern int fputc(int, FILE *);
  264. extern int fputs(char *, FILE *);
  265. extern int getc(FILE *);
  266. extern int getchar(void);
  267. extern char *gets(char *);
  268. extern int putc(int, FILE *);
  269. extern int putchar(int);
  270. extern int puts(char *);
  271. extern int ungetc(int, FILE *);
  272.  
  273. extern size_t fread(void *, size_t, size_t, FILE *);
  274. extern size_t fwrite(void *, size_t, size_t, FILE *);
  275.  
  276. extern int fgetpos(FILE *, fpos_t *);
  277. extern int fseek(FILE *, long, int);
  278. extern int fsetpos(FILE *, fpos_t *);
  279. extern long ftell(FILE *);
  280. extern void rewind(FILE *);
  281.  
  282. extern void clearerr(FILE *);
  283. extern int feof(FILE *);
  284. extern int ferror(FILE *);
  285. extern void perror(char *);
  286. int send(char *fmt, ...);
  287. int print(char *fmt, ...);
  288. int sendtext(char *file);
  289. int wait(int secs);
  290. char cmd1(char *parmN);
  291. char cmd1noecho(char *parmN);
  292. int sendnc(char *parmN);
  293. int showline(void);
  294.  
  295. int portsin(char *buf, int max);
  296. int passportsin(char *buf, int max);
  297. int module(int mode, char *name, struct PPP *P);
  298. int gettime(char *format, char *datea);
  299. int switchuser(void);
  300.  
  301. int HandleEvent(int type);
  302. int otheruser(int type);
  303. int mackey(void);
  304. int loguser(char *what);
  305. int printout(unsigned int tmp);
  306. int versionck(double number);
  307. int searchs(char *ck, char *s, char *check, int *where, int *theone);
  308.  
  309. int removespaces(char *temp);
  310. int pStrCopy(char *p2, char *p1);
  311. int strtoupper(char *str1);
  312. int strcatc(char *str, int c);
  313. int strtolong(long *n, char *str);
  314. int longtostr(long n, char *str);
  315. int strtoint(char *str);
  316. int inttostr(int n, char *str);
  317. int getdatetime(char *datetime);
  318.  
  319. #endif
  320.  
  321. /* this should allow you to access these routines */
  322.  
  323. int __getc(FILE *);
  324. int __putc(int, FILE *);
  325.  
  326. #define getc(fp)    ((fp)->cnt-- ? (int) *(fp)->ptr++ : __getc(fp))
  327. #define getchar()    getc(stdin)
  328.  
  329. #define putc(c, fp)    ((fp)->cnt-- > 1 ? (int) (*(fp)->ptr++ = (c)) : __putc(c, fp))
  330. #define putchar(c)    putc(c, stdout)
  331.  
  332. #define ferror(fp)    ((int) (fp)->err)
  333. #define feof(fp)    ((int) (fp)->eof)
  334.  
  335.  
  336.  
  337.